package com.shuyu.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.shuyu.common.annotation.Excel;
import com.shuyu.common.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

@Data
@ApiModel(description = "用户行为记录")
@TableName("tbl_customer_behavior")
public class CustomerBehavior implements Serializable {
    private static final long serialVersionUID = 1299483239506817612L;
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    @ApiModelProperty(value = "事件ID")
    @Excel(name = "事件ID",sort = 2)
    private Long eventId;
    @ApiModelProperty(value = "用户ID")
    @Excel(name = "用户ID",sort = 1)
    private String customerId;
    @ApiModelProperty(value = "一级行为")
    @Excel(name = "事件说明",sort = 3)
    private String levelOne;
    @ApiModelProperty(value = "二级行为")
    private String levelTwo;
    @ApiModelProperty(value = "三级行为")
    private String levelThree;
    private transient String behavior;
    @ApiModelProperty(value = "开始时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "开始时间",sort = 4, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;
    @ApiModelProperty(value = "持续时间")
    @Excel(name = "持续时间",sort = 5,suffix="S")
    private Long duration;
    @ApiModelProperty(value = "结束时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    private Date createTime;

    public String getBehavior() {
        String str = "";
        if(StringUtils.isNotEmpty(levelOne)){
            str += levelOne;
        }
        if(StringUtils.isNotEmpty(levelTwo)){
            str += levelTwo;
        }
        if(StringUtils.isNotEmpty(levelThree)){
            str += levelThree;
        }
        return str;
    }

}
